@extends('frontend/layouts/bootstrap')

@section('content')
<h1>Сэлбэг бүртгэх</h1>

{{ Form::open(array('route' => 'car_balance.parts.create')) }}

<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
        <th>Customer</th>
        <th title="Date">日付</th>
        <th>Auction ID</th>
        <th>Parts name</th>
        <th>Seller</th>
        <th title="Seller send type">販売店発送</th>
        <th title="Pickup car chassis number">積込車両車体番号</th>
    </thead>

    <tr>
        <td{{ $errors->first('customer_id', ' class="control-group error"') }}>
            {{ Form::select('customer_id', $customer_list, '', array('data-placeholder' => 'Customer', 'class' => 'span2', 'name' => 'customer_id')) }}
            {{ $errors->first('customer_id', '<span class="help-inline">:message</span>') }}
        </td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'purchase_date', 'value' => date('Y-m-d')))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'auction_id'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'parts_name'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'seller'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'seller_send_type'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'Pickup_car_chassis_number'))
    </tr>
</table>
<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
        <th>Payment type</th>
        <th>Payment date</th>
        <th title="Payment">入金</th>
        <th>Price</th>
        <th>Delivery</th>
        <th>Commission</th>
        <th>Fee (mongol)</th>
    </thead>

    <tr>
        <td><select name="payment_type" id="payment_type">
                <option value="Cash">Cash</option>
                <option value="Yahoo">Yahoo</option>
                <option value="Bank">Bank</option>
            </select></td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'payment_date'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'payment_commission'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'price'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'delivery_fee'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'commission'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'fee_mongol'))
    </tr>
</table>

<button type="submit" class="btn btn-large btn-success"><i class="icon-plus icon-white"></i> Бүртгэх</button> &nbsp;&nbsp;

{{ Form::close() }}
@stop


@section('pagescripts')
<!--page specific plugin scripts-->
<script type="text/javascript" >
    $(document).ready(function(){
        if($('input[name=purchase_date]').val() == '') {
            var d = new Date();

            var month = d.getMonth()+1;
            var day = d.getDate();

            var output = d.getFullYear() + '-' +
                (month<10 ? '0' : '') + month + '-' +
                (day<10 ? '0' : '') + day;

            $('input[name=purchase_date]').val(output);
        }
    });
</script>
@stop